package com.yorick.resource.enums;

import lombok.Getter;
import lombok.Setter;

@Getter
public enum FileType {
    FOLDER("folder", 0),
    JPG("jpg", 1),
    JPEG("jpeg", 1),
    PNG("png", 1),
    GIF("gif", 1),
    MP4("mp4", 2),
    WMV("wmv", 2),
    MOV("mov", 2),
    FLV("flv", 2),
    AVI("avi", 2),
    ZIP("zip", 3),
    RAR("rar", 3),
    OTHER("other", 4),
    MP3("mp3", 5),
    WMA("wma", 5),
    AAC("aac", 5),
    FLAC("flac", 5),
    TXT("txt",6),
    SQL("sql",6),
    ;

    private String fileTypeName;
    private int fileTypeCode;

    FileType(String fileTypeName, int fileTypeCode) {
        this.fileTypeName = fileTypeName;
        this.fileTypeCode = fileTypeCode;
    }

    // 根据value返回枚举类型,主要在switch中使用
    public static FileType getByValue(String value) {
        for (FileType fileType : values()) {
            if (fileType.getFileTypeName().equals(value)) {
                return fileType;
            }
        }
        return OTHER;
    }

}
